#include "Timer.h"

Timer::Timer(){
	 deltaTime = measureFpsSample = frameCounter = FPS = 0;
}

void Timer::FirstMeasure(){
	QueryPerformanceFrequency(&frecuency);
	QueryPerformanceCounter(&lastTime);
}

void Timer::Measure(){
	QueryPerformanceCounter(&actualTime);

	deltaTime = static_cast<double>((actualTime.QuadPart-lastTime.QuadPart)*1000.0f/frecuency.QuadPart);

	lastTime=actualTime;

	frameCounter++;
	measureFpsSample+=deltaTime;

	if(measureFpsSample>=1000){
		measureFpsSample-=1000;
		FPS = frameCounter;
		frameCounter=0;
	}
}

unsigned int Timer::GetFPS(){
	return FPS;
}